#include "ControlPoint.h"
#include <QKeyEvent>
#include "Global.h"

ControlPoint::ControlPoint(QPointF pos,int num,qreal x, qreal y, qreal w, qreal h,QGraphicsItem* parent)
    : QGraphicsEllipseItem(x,y,w,h,parent),
      MutaObject("cP",Muta::ControlPoint," "),
      time(0)
{
    setPos(pos);
    this->num = num;
    setFlag( QGraphicsItem::ItemIsSelectable, true );
    setFlag( QGraphicsItem::ItemIsMovable, true );
    setFlag( QGraphicsItem::ItemIsFocusable, true );
    setFlag( QGraphicsItem::ItemIgnoresTransformations, true);
}

void ControlPoint::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
    QGraphicsEllipseItem::mouseMoveEvent(event);

    emit mouseMoved(this->pos(),num);
}

void ControlPoint::setPos(const QPointF &pos) {
    QGraphicsEllipseItem::setPos(pos);
}

int ControlPoint::type() const
{
    return Muta::ControlPoint;
}

void ControlPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    time++;
    if(time > 6 ) {
        QGraphicsEllipseItem::paint(painter,option,widget);
    }
}
